﻿<Window x:Class="Convertor.AboutUs"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:local="clr-namespace:Convertor"
        xmlns:interf="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
        xmlns:control="clr-namespace:Convertor.Control"
        xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        TextOptions.TextFormattingMode="Display"
        Title="{DynamicResource About}" 
        Width="700" 
        Icon="Images/Help.png"
        SizeToContent="Height"
        Loaded="Window_Loaded"
        KeyDown="Window_KeyDown"
        KeyUp="Window_KeyUp">
    <Window.Resources>
        <local:PluginIconConverter x:Key="PluginIconConverter"/>
        <local:PluginDetailConverter x:Key="PluginDetailConverter"/>
        <local:PluginInstallConverter x:Key="PluginInstallConverter"/>
        <local:AllPluginToNamesConverter x:Key="AllPluginToNamesConverter"/>
        <conv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </Window.Resources>
    <Window.Background>
        <ImageBrush ImageSource="Images/Bg-1.png"/>
    </Window.Background>
    <Grid Background="{StaticResource MainBackgroundOpacityMask}">
        <DockPanel Background="#88F5F3F3">
            <Border Padding="5" DockPanel.Dock="Top" Background="White">
                <Border.Effect>
                    <DropShadowEffect Opacity="0.1" BlurRadius="3"/>
                </Border.Effect>
                <DockPanel Margin="5">
                    <Image Source="Images/logo.png" Grid.Column="0"  DockPanel.Dock="Left" Width="200"/>
                    <StackPanel >
                        <WrapPanel>
                            <TextBlock Text="{DynamicResource Help_LicensedTo}" Width="80" Height="20" Padding="0" Margin="0"/>
                            <TextBlock Text="{Binding Source={StaticResource Config}, Path=HelpContent.MachineName}" Height="20" Padding="0" Margin="0"/>
                        </WrapPanel>
                        <WrapPanel>
                            <TextBlock Text="{DynamicResource Help_Version}" Width="80" Height="20" Padding="0" Margin="0"/>
                            <TextBlock Text="{Binding Source={StaticResource Config}, Path=HelpContent.Version}" Height="20" Padding="0" Margin="0"/>
                        </WrapPanel>
                        <WrapPanel>
                            <TextBlock Text="(C) " Height="20" Padding="0" Margin="0"/>
                            <TextBlock Text="{Binding Source={StaticResource Config}, Path=HelpContent.CompanyName}" Height="20" Padding="0" Margin="0"/>
                        </WrapPanel>
                    </StackPanel>
                </DockPanel>
            </Border>
            <Grid DockPanel.Dock="Top" Margin="5,10,5,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <DockPanel Grid.Column="0" >
                    <AdornerDecorator DockPanel.Dock="Top">
                        <Border Style="{StaticResource BorderShadowStyle}">
                            <ListBox x:Name="AllPluginList" Style="{StaticResource NoneStyle}" Height="150"
                                 HorizontalContentAlignment="Stretch" Padding="0,0,0,10">
                                <ListBox.ItemsSource>
                                    <MultiBinding Converter="{StaticResource AllPluginToNamesConverter}" >
                                        <Binding Source="{x:Static local:Config.GlobalConfig}" Path="AllPlugins"/>
                                        <Binding Source="{x:Static sys:String.Empty}"/>
                                        <Binding Source="{x:Null}" Path="DisabledPlugins"/>
                                    </MultiBinding>
                                </ListBox.ItemsSource>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <DockPanel Margin="1">
                                            <TextBlock Text="{Binding Path=., Converter={StaticResource PluginDetailConverter}, ConverterParameter='Version'}" Foreground="Gray" DockPanel.Dock="Right" />
                                            <Image Source="{Binding Path=Name, Converter={StaticResource PluginIconConverter}}" Width="16" Margin="0,0,3,0" DockPanel.Dock="Left"/>
                                            <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}" DockPanel.Dock="Left">
                                                <TextBlock.Foreground>
                                                    <MultiBinding Converter="{StaticResource PluginInstallConverter}" ConverterParameter="Foreground" Mode="OneWay" NotifyOnSourceUpdated="True">
                                                        <Binding Path="." />
                                                        <Binding Source="{x:Static local:Config.GlobalConfig}" Path="DisabledPlugins"/>
                                                    </MultiBinding>
                                                </TextBlock.Foreground>
                                            </TextBlock>
                                        </DockPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <sm:WatermarkService.Titlemark>
                                    <TextBlock Text="{DynamicResource Help_AllInstalledPlugin}" TextAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,20,-8"/>
                                </sm:WatermarkService.Titlemark>
                            </ListBox>
                        </Border>
                    </AdornerDecorator>
                    <AdornerDecorator DockPanel.Dock="Top" Margin="0,3,0,0">
                        <Border Style="{StaticResource BorderShadowStyle}">
                            <TextBox DockPanel.Dock="Top" Height="110" IsReadOnly="True"
                                     Style="{StaticResource NoneStyle}"
                                     Text="{Binding ElementName=AllPluginList, Path=SelectedItem, Mode=OneWay, Converter={StaticResource PluginDetailConverter}}">
                                <sm:WatermarkService.Titlemark>
                                    <TextBlock Text="{DynamicResource Help_PluginDetail}" TextAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,20,0"/>
                                </sm:WatermarkService.Titlemark>
                            </TextBox>
                        </Border>
                    </AdornerDecorator>
                </DockPanel>
                <DockPanel Grid.Column="1" Margin="2,0,0,0">
                    <DockPanel.Effect>
                        <DropShadowEffect Opacity="0.2" ShadowDepth="3"/>
                    </DockPanel.Effect>
                    <Button DockPanel.Dock="Top" VerticalAlignment="Top" Padding="0,5,0,5" Margin="0"
                            Click="DeleteOrAddPlugin_Click">
                        <Button.Content>
                            <MultiBinding Converter="{StaticResource PluginInstallConverter}" ConverterParameter="Content">
                                <Binding ElementName="AllPluginList" Path="SelectedItem" />
                                <Binding Source="{x:Static local:Config.GlobalConfig}" Path="DisabledPlugins"/>
                            </MultiBinding>
                        </Button.Content>
                        <Button.IsEnabled>
                            <MultiBinding Converter="{StaticResource PluginInstallConverter}" ConverterParameter="IsEnabled">
                                <Binding ElementName="AllPluginList" Path="SelectedItem" />
                                <Binding Source="{x:Static local:Config.GlobalConfig}" Path="DisabledPlugins"/>
                            </MultiBinding>
                        </Button.IsEnabled>
                    </Button>
                </DockPanel>
            </Grid>
            <Border DockPanel.Dock="Top" Style="{StaticResource WhiteMask}" Margin="0,10,0,0">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <control:Loading x:Name="Loading"/>
                    <Label x:Name="lbUpdate" Visibility="{Binding Source={x:Static local:Config.GlobalConfig }, Path=HasUpdate, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Hyperlink Click="Update_Click">
                            <TextBlock Text="{DynamicResource Help_Update_Url}"></TextBlock>
                        </Hyperlink>
                    </Label>
                    <Label>
                        <Hyperlink Click="Support_Click">
                            <TextBlock Text="{DynamicResource Help_Visit}"></TextBlock>
                        </Hyperlink>
                    </Label>
                </StackPanel>
            </Border>
        </DockPanel>
    </Grid>
</Window>
